#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10, M = 2 * N;
int h[M], e[M], ne[M], idx, w[M];
int f[M][22], dis[M];
LL ans[M], ans1[M];
int n, m;
void add(int a, int b, int c)
{
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx++;
}
void dfs(int u, int fa)
{
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (j != fa) {
			dis[j] = dis[u] + 1;
			f[j][0] = u;
			for (int i = 1; (1 << i) <= dis[j]; i++) {
				f[u][i] = f[f[u][i - 1]][i - 1];
			}
			dfs(j, u);
		}
	}
}

int lca(int a, int b)
{
	if (dis[a] < dis[b])swap(a, b);
	int d = dis[a] - dis[b];
	for (int i = 0; d; i++) {
		if (d & 1)a = f[a][i];
		d /= 2;
	}
	if (a == b)return a;
	for (int i = 20; i >= 0; i--) {
		if (f[a][i] != f[b][i]) {
			a = f[a][i];
			b = f[b][i];
		}
	}
	return f[a][0];
}

void dfs2(int u, int fa)
{
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (j != fa) {
			dfs2(j, u);
			ans[u] += ans[j];
			ans1[w[i]] = ans[j];
		}
	}
}
int main()
{
	cin >> n;
	memset(h, -1, sizeof(h));
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b, i);
		add(b, a, i);
	}
	dis[1] = 1;
	dfs(1, 0);
	cin >> m;
	/*for (int i = 1; i <= n; i++) {
		cout << "i==" << i << "   " << dis[i] << endl;
	}*/
	//cout << " ----" << f[5][0] << "  " << f[5][1] << endl;
	while (m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		//cout << "lca(a,b)===" << lca(a, b) << endl;
		ans[a]++, ans[b]++; ans[lca(a, b)] -= 2;
	}
	//cout << ans[3] << " --" << ans[5] << endl;
	dfs2(1, 0);
	for (int i = 1; i < n; i++) {
		cout << ans1[i] << " ";
	}
	return 0;
}